#include <bits/stdc++.h>

using namespace std;

const int N=5010;

int n,s,a,b;
struct node
{
	int x,y;
}e[N];

bool cmp(node& a,node& b)
{
	return a.y<b.y;
}

int main() 
{
	cin>>n>>s>>a>>b;
	int t=a+b;
	for(int i=1;i<=n;i++) cin>>e[i].x>>e[i].y;
	
	int cnt=0;
	sort(e+1,e+1+n,cmp);
	
	for(int i=1;i<=n;i++)
	{
		if(t>=e[i].x&&s>=e[i].y)
		{
			cnt++;
			s-=e[i].y;
		}
	}
	cout<<cnt<<endl;
	return 0;
}
